<?php
if (!empty($parentMenu))
{
	$this->breadcrumbs=array(
		tt('Menu')=>array('index'),
		$menu->title=>array('view', 'id'=>$menu-id),
		$parentMenu->{'title_'.Yii::app()->language}
	);
}
else
{
	$this->breadcrumbs=array(
		tt('Menu')=>array('index'),
		$menu->title,
	);
}

$this->h1 = $menu->title;
if (!empty($parentMenu))
{
	$this->h1 .= " > ".$parentMenu->{'title_'.Yii::app()->language};
}
?>

<?php

echo CHtml::htmlButton(
		tt('Add Item'), 
		array(
			'class'=>'button grey', 
			'onclick'=>'document.location.href="'.Yii::app()->createAbsoluteUrl(
					"/menu/admin/default/createitem", 
					array('id'=>$menu->id,'parent'=>$parent)).'"'
			)
);


$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'news-grid',
	'cssFile'=>Yii::app()->theme->baseUrl.'/css/tables.css',
	'itemsCssClass'=>'item-class',
	'pagerCssClass'=>'pager-class',
	'dataProvider'=>$model->search($menu->id, $parent),
	'columns'=>array(
		array(
			'name' => 'id',
			'htmlOptions' => array('class'=>'grid-status-column'),
			'sortable' => false,
		),
		
		array(
			'name' => 'title_'.Yii::app()->language,
			'sortable' => false,
		),
		
		array(
			'class'=>'CButtonColumn',
			'template'=>'{up}{down}{update}{view}{delete}',
			'deleteConfirmation' => tt('Are you sure you want to delete this menu item?'),
			'htmlOptions' => array('class'=>'button-column'),
			'buttons' => array(
				'up' => array(
					'label' => tt('Move menu item up'),
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/bullet_arrow_up.png',
					'url'=>'Yii::app()->createUrl("/menu/admin/default/move", array("id"=>$data->id, "direction" => "up"))',
					'visible' => '$data->sorter > 1',
				),
				'down' => array(
					'label' => tt('Move menu item down'),
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/bullet_arrow_down.png',
					'url'=>'Yii::app()->createUrl("/menu/admin/default/move", array("id"=>$data->id, "direction" => "down"))',
					'visible' => '$data->sorter < "'.$maxSorter.'"',
				),
				'update' => array(
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/icon_edit.png',
					'url'=>'Yii::app()->createUrl("/menu/admin/default/updateitem", array("id"=>$data->id))',
				),
				'view' => array(
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/icon_view.png',
					'url'=>'Yii::app()->createUrl("/menu/admin/default/view", array("id"=>'.$menu->id.', "parent"=>$data->id))',
				),
				'delete' => array(
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/icon_delete.png',
					'url'=>'Yii::app()->createUrl("/menu/admin/default/deleteitem", array("id"=>$data->id))',
				),
			),
		),
	),
));
	
?>